// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from "vue";
import Vuex from "vuex";
import App from "./App";
import axios from "axios";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import * as echarts from "echarts";
import store from "./vuex/store.js";
import "./assets/style/table.scss";
import ECharts from "vue-echarts/components/ECharts.vue";
import Print from "vue-print-nb";
import Viewer from "v-viewer";
import "viewerjs/dist/viewer.css";
import ViewUI from "view-design";
import "view-design/dist/styles/iview.css";
import global from "./components/global.vue";
import router from "./router";

// 引入图标自动注册
import "@/assets/icons";

import VueAwesomeSwiper from "vue-awesome-swiper";
import "swiper/dist/css/swiper.css";
Vue.use(VueAwesomeSwiper);

Vue.use(Viewer);
Viewer.setDefaults({
    Options: {
        inline: false,
        button: true,
        navbar: true,
        title: true,
        toolbar: true,
        tooltip: true,
        movable: true,
        zoomable: true,
        rotatable: true,
        scalable: true,
        transition: true,
        fullscreen: true,
        keyboard: true,
        url: "data-source",
    },
});
Vue.use(Print);
Vue.use(ElementUI);
Vue.use(Vuex);
Vue.use(ViewUI);
Vue.component("chart", ECharts);
Vue.config.productionTip = false;
Vue.directive("preventReClick", {
    inserted(el, binding) {
        el.addEventListener("click", () => {
            if (!el.disabled) {
                el.disabled = true;
                setTimeout(() => {
                    el.disabled = false;
                }, binding.value || 2000);
            }
        });
    },
});
// Vue.prototype.$axios = axios;
Vue.prototype.$echarts = echarts;
Vue.prototype.$Global = global;
axios.defaults.withCredentials = false;
global.bus = new Vue();

// 导入时间格式化组件库moment
import moment from "moment";
// 定义一个全局的过滤器
Vue.filter("dateFormat", function (data, fmt) {
    return moment(data).format(fmt);
});
Vue.prototype.$moment = moment;

import { addColor } from "./assets/theme/configColor.js";

router.beforeEach((to, from, next) => {
    addColor();
    next();
});

// export const eventBus = new Vue();

new Vue({
    el: "#app",
    router,
    store,
    components: {
        App,
    },
    template: "<App/>",
});
